package day0;

import java.util.*;

public class Solution {

    public int[] twoSum(int[] nums, int target) {
        //list set map queue stack
        HashMap<Integer,Integer> map = new HashMap<>();
        for (int i = 0; i < nums.length; i++) {
            int num = nums[i];
            int req = target- nums[i];
            if(map.containsKey(req)){
                return new int[]{map.get(req),i};
            }else {
                map.put(num,i);
            }
        }
        return  new int[]{0,0};
    }

    public List<List<String>> groupAnagrams(String[] strs) {
        List<List<String>> list = new ArrayList<>();
        HashMap<String,List<String>> map = new HashMap<>();

        for(String str:strs){
            char[] ch = str.toCharArray();
            Arrays.sort(ch);
            String s = new String(ch);
            if(map.containsKey(s)){
                map.get(s).add(str);
            }else {
                ArrayList<String> l = new ArrayList<>();
                l.add(str);
                map.put(s,l);
            }
        }
        for(String str:map.keySet()){
            list.add(map.get(str));
        }
        return list;
    }

    public int longestConsecutive(int[] nums) {
        HashSet<Integer> set = new HashSet<>();
        for(int i:nums){
            set.add(i);
        }

        int result = 0;
        for(int i:set){
            if(!set.contains(i-1)){
                int sum = 1;
                int num = i+1;
                while (set.contains(num)){
                    sum += 1;
                    num += 1;
                }
                result = Math.max(sum,result);

            }
        }
        return result;
    }




    public static void main(String[] args) {
        int[] arr = new int[4];

        Scanner sc = new Scanner(System.in);
        String[] str = sc.nextLine().split(" ");



    }

}
